const app = getApp()
import {imageUrl} from "../../utils/imageutil.js"
Page({
  data: {
    imageUrl:imageUrl,
    servecurr:1,
    serveList:[{
      title:'做饭做家务',
      id:1,
      icon:'cook',
      iconSelect:'cookSelect'
    },{
      title:'照顾小孩',
      id:2,
      icon:'child',
      iconSelect:'childSelect'
    },{
      title:'照顾老人',
      id:3,
      icon:'old',
      iconSelect:'oldSelect'
    }],
    multiIndex:[0,0,0,0,0],
    addressid:'',
    myDefaultAddress:'',
    money:0,
  },
  onLoad: function (options) {
    let date = new Date()
    const month = date.getMonth() 
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    this.setData({
      multiIndex:[0,month,day-1,hour,minute]
    })
  },
  onShow(){
    this.getMyDefaultAddress()
  },
  minusmoney(){
    if(this.data.money-100<=0){
      this.setData({
        money:0
      })
    }else{
      this.setData({
        money:this.data.money-100
      })
    }
  },
  addmoney(){
    this.setData({
      money:this.data.money+100
    })
  },
  toMyAddress(){
    wx.navigateTo({
      url: '../matron/address',
    })
  },
  getMyDefaultAddress(){
    app.globalData.post({
      data:{
        do:"MyDefaultAddress",
        user_id:wx.getStorageSync('userInfo').id
      }
    }).then(res=>{
      if(res.data==false){
        this.setData({
          myDefaultAddress:null,
          addressid:''
        })
      }else{
        this.setData({
          myDefaultAddress:res.data,
          addressid:res.data.id
        })
      }
    })
  },
  serveChange(e){
    this.setData({
      servecurr:e.currentTarget.dataset.id
    })
  },
  getTime(e){
    console.log(e.detail)
  },
})